package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.ProductSerialBalanceEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @date 2020/5/19
 */
public interface ProductSerialBalanceModel extends IModel<ProductSerialBalanceEntity> {

    /**
     * 查询流水结存
     *
     * @param param 参数
     * @return 结存
     */
    @Override
    List<ProductSerialBalanceEntity> findEntitys(@Param("param") Map<String, Object> param);

    /**
     * 数量查询
     *
     * @param param 参数
     * @return 数量
     */
    @Override
    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    void insertBatch(List<ProductSerialBalanceEntity> productSerialBalanceList) throws XbbException;

    Integer updateBatch(List<ProductSerialBalanceEntity> entitys, String corpid) throws XbbException;

    /**
     * 批量更新序列号
     *
     * @param corpid       公司id
     * @param refIdIn      入库单id
     * @param businessType 业务类型
     * @throws XbbException 异常
     */
    void deleteSerial(String corpid, List<Long> refIdIn, Integer businessType) throws XbbException;

    /**
     * 删除
     * @param corpid
     * @param refIdIn
     * @param businessType
     * @param enableSerialProductIds
     * @throws XbbException
     */
    Integer deleteBatch(List<Long> refIdIn, String corpid, Integer businessType, List<Long> enableSerialProductIds);
    /**
     * 根据关联产品id和业务类型删除
     * @param refIdIn
     * @param corpid
     * @param businessType
     * @param refProductIds
     * @return java.lang.Integer
     * @author 吴峰
     * @date 2022/3/29 10:15
     * @throws XbbException
     */
    Integer deleteBatchByRefProductId(List<Long> refIdIn, String corpid, Integer businessType, List<Long> refProductIds);


    List<ProductSerialBalanceEntity> getByRefProductId(Long id, int code, String corpid);

    void deleteByRefId(Long refId, Integer businessType, String corpid);

    ProductSerialBalanceEntity getByKey(Long key, String corpid);

    List<ProductSerialBalanceEntity> getBalanceByRefIdAndBusiness(List<Long> refIdIn, String corpid, Integer businessType);

    List<ProductSerialBalanceEntity> getBySeqKeyList(List<String> seqKeyList, String corpid);

    void updateBatchByParentId(String corpid, Long parentId, Integer visible);

}
